﻿CREATE TABLE [dbo].[ProductStocks] (
    [ID]           INT             IDENTITY (1, 1) NOT NULL,
    [ProductID]    INT             NOT NULL,
    [MaterialID]   INT             NOT NULL,
    [ProcessID]    INT             NOT NULL,
    [Size]         VARCHAR (50)    CONSTRAINT [DF_ProductStocks_Size] DEFAULT ('无') NOT NULL,
    [Quantity]     DECIMAL (18, 5) NOT NULL,
    [LastUpdateOn] DATETIME        CONSTRAINT [DF_ProductStocks_LastUpdateOn] DEFAULT (getdate()) NOT NULL,
    [HouseID]      INT             CONSTRAINT [DF_ProductStocks_HouseID] DEFAULT ((1)) NOT NULL,
    CONSTRAINT [PK_ProductStocks] PRIMARY KEY CLUSTERED ([ID] ASC),
    CONSTRAINT [FK_ProductStocks_ProductMaterials] FOREIGN KEY ([MaterialID]) REFERENCES [dbo].[ProductMaterials] ([ID]),
    CONSTRAINT [FK_ProductStocks_ProductProcesses] FOREIGN KEY ([ProcessID]) REFERENCES [dbo].[ProductProcesses] ([ID]),
    CONSTRAINT [FK_ProductStocks_Products] FOREIGN KEY ([ProductID]) REFERENCES [dbo].[Products] ([ID]),
    CONSTRAINT [FK_ProductStocks_Warehouses] FOREIGN KEY ([HouseID]) REFERENCES [dbo].[Warehouses] ([ID])
);



